package com.lwm.controller;

import com.lwm.domain.ResponseResult;
import com.lwm.domain.User;
import com.lwm.service.LoginService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/user")
@Slf4j
public class LoginController {
    @Resource
    private LoginService loginService;

    @PostMapping("/login")
    public ResponseResult<Object> login(@RequestBody User user) {
        return loginService.login(user);
    }

    @GetMapping("/info")
    public ResponseResult<Object> info(String token) {
        log.info("获取用户信息 token: {}", token);
        return loginService.getInfo(token);
    }

    @PostMapping("/logout")
    public ResponseResult<Object> logout() {
        return loginService.logout();
    }
}
